/**
 * Created by lifangfang on 2015/7/18.
 */

$(document).ready(function(){
    document.getElementById("text").checked=false;
    document.getElementById("photo").checked=false;
	
	$(".printButton").click(function(){
        $(".printForm").slideToggle("slow");
        $('html,body').animate({
                scrollTop: 500
            },
            700)
    });
	
    $("#text").click(function(){
        if(document.getElementById("text").checked==true){
            $("#textStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="text"&&this.name=="printType"){
                $("#textStandard").css({display:'none'});
            }
        });
    });
	
    $("#photo").click(function(){
        if(this.checked==true){
            $("#photoStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="photo"&&this.name=="printType"){
                $("#photoStandard").css({display:'none'});
            }
        });
    });
     $("#book").click(function(){
        if(this.checked==true){
            $("#bookStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="book"&&this.name=="printType"){
                $("#bookStandard").css({display:'none'});
            }
        });
    });
	 $("#portable").click(function(){
        if(this.checked==true){
            $("#portableStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="portable"&&this.name=="printType"){
                $("#portableStandard").css({display:'none'});
            }
        });
    });
	
	$("#brush").click(function(){
        if(this.checked==true){
            $("#brushStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="brush"&&this.name=="printType"){
                $("#brushStandard").css({display:'none'});
            }
        });
    });
	
	$("#DM").click(function(){
        if(this.checked==true){
            $("#DMStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="DM"&&this.name=="printType"){
                $("#DMStandard").css({display:'none'});
            }
        });
    });
	$("#poster").click(function(){
        if(this.checked==true){
            $("#posterStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="poster"&&this.name=="printType"){
                $("#posterStandard").css({display:'none'});
            }
        });
    });
	$("#banner").click(function(){
        if(this.checked==true){
            $("#bannerStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="banner"&&this.name=="printType"){
                $("#bannerStandard").css({display:'none'});
            }
        });
    });
	
	$("#card").click(function(){
        if(this.checked==true){
            $("#cardStandard").css({display:'block'});
        }
        $("input").click(function(){
            if(this.id!="card"&&this.name=="printType"){
                $("#cardStandard").css({display:'none'});
            }
        });
    });
    //设计块的出现
    $(".designBtn").click(function(){
        $(".qqForm").slideToggle("slow");
        $('html,body').animate({
                scrollTop: 500
            },
            700)
    });
     //修改收货地址信息
    $("#addressSet").hover(function () {
        $(this).stop().animate({
            opacity: '1'
        }, 600);
    }, function () {
        $(this).stop().animate({
            opacity: '0.6'
        }, 1000);
    }).click( function () {
        $("body").append("<div id='mask'></div>");
        $("#mask").addClass("mask").fadeIn("slow");
        $(".addressBox").fadeIn("slow");
        var address =document.getElementById("deflautaddress").innerHTML;
        var name = document.getElementById("deflautname").innerHTML;
        var phoneNumber = document.getElementById("deflautphonenumber").innerHTML;

        document.getElementById("address").value=address;
        document.getElementById("name").value=name;
        document.getElementById("phoneNumber").value=phoneNumber;
    });
    $(".close_btn").hover(function () { $(this).css({ color: 'black' }) }, function () { $(this).css({ color: '#999' }) }).click( function () {
        $(".addressBox").fadeOut("fast");
        $("#mask").css("display","none");
    });

    //修改地址的表单出现
    $("#addressBtn").click(function(){
        var name=document.getElementById("name").value;
        var phoneNumber=document.getElementById("phoneNumber").value;
        var address=document.getElementById("address").value;
        document.getElementById("deflautaddress").innerHTML=address;
        document.getElementById("deflautname").innerHTML=name;
        document.getElementById("deflautphonenumber").innerHTML=phoneNumber;

        $(".addressBox").fadeOut("fast");
        $("#mask").css({ display: 'none' });

    });

    $("input[type=file]").change(function(){
        $(this).parents(".uploader").find(".filename").val($(this).val());
    });

    $("input[type=file]").each(function(){
        if($(this).val()==""){
            $(this).parents(".uploader").find(".filename").val("请选择文件...");
        }
    });
	
	$(".user").mouseover(function(){
        $(".me").css("display","block");
        $(".me").css("z-index","1000");
        });
        $(".user").mouseout(function() {
        $(".me").css("display", "none");
        $(".me").css("z-index","-1");
		});  
});
